import Vue from 'vue';
import VueRouter from 'vue-router';
import Project from '@/views/project.vue';
import Board from '@/views/board.vue';
import Lesson from '@/views/lesson.vue';
import Repcard from '@/views/report-card.vue';
import Scomanage from '@/views/score-manage.vue';
import Statistics from '@/views/statistics.vue';
import Stumanage from '@/views/stu-manage.vue';
import Sysmanage from '@/views/system-manage.vue';
import Task from '@/views/task.vue';
import Onload from '@/views/onload.vue';
import mission from '@/components/tasktab/misinfo&intro.vue';
import projectDetail from '@/components/project/projectDetail.vue';
import agileproject from '@/components/project/agileproject.vue';
import Mineinfo from '@/views/mine/mineinfo.vue';
import Mycomment from '@/views/mine/mycomment.vue';
import ReportInfo from '@/components/repcard/reportInfo/reportInfo.vue';
import ScoreDetails from '@/components/scoreManage/ScoringDetails.vue';
import CoursePreparation from '@/components/lesson-preparation/myLesson/CoursePreparation.vue';
import ResourcesMaterial from '@/components/lesson-preparation/myLesson/ResourcesMaterial.vue';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'Onload',
    component: Onload,
    meta: {
      keepAlive: false
    }
  },
  {
    path: '/mineinfo',
    name: 'Mineinfo',
    component: Mineinfo,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/mycomment',
    name: 'Mycomment',
    component: Mycomment,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/misinfo&intro',
    name: 'Misinfo&intro',
    component: mission,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/project',
    name: 'Project',
    component: Project,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/board',
    name: 'Board',
    component: Board,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/lesson',
    name: 'Lesson',
    component: Lesson,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/report-card',
    name: 'Repcard',
    component: Repcard,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/reportInfo',
    name: 'ReportInfo',
    component: ReportInfo,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/score-manage',
    name: 'Scomanage',
    component: Scomanage,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/statistics',
    name: 'Statistics',
    component: Statistics,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/stu-manage',
    name: 'Stumanage',
    component: Stumanage,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/system-manage',
    name: 'Sysmanage',
    component: Sysmanage,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/task',
    name: 'Task',
    component: Task,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/projectdetail',
    name: 'Prodetail',
    component: projectDetail,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/agileproject',
    name: 'Agileproject',
    component: agileproject,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/scoreDetails',
    name: 'ScoreDetails',
    component: ScoreDetails,
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/coursePreparation',
    name: 'CoursePreparation',
    component: CoursePreparation,
    meta: {
      keepAlive: true
    }
  },
  // ResourcesMaterial
  {
    path: '/resourcesMaterial',
    name: 'ResourcesMaterial',
    component: ResourcesMaterial,
    meta: {
      keepAlive: true
    }
  }
];

const router = new VueRouter({
  mode: 'hash',
  base: '',
  routes
});

// router.beforeEach((to, from, next) => {
//   let isLogin = this.$store.state.headerMenu;
//   if (isLogin) {
//     // 如果用户信息存在则往下执行。
//     next();
//   } else {
//     // 如果用户token不存在则跳转到login页面
//     if (to.path === '/') {
//       next();
//     } else {
//       next('/');
//     }
//   }
// });

export default router;
